﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;
using System.ServiceModel.Activation;
using System.ServiceModel.Web;
using Newtonsoft.Json;

namespace GalaxyFutures.PinganAsset
{
    public class MarketPriceBar 
    {
        public DateTime TradingDay { get; set; }
        public double OpenPrice { get; set; }
        public double ClosePrice { get; set; }
        public double HighestPrice { get; set; }
        public double LowestPrice { get; set; }
    }

    [ServiceContract(Namespace = "skyline.com")]
    [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
    public class DataService
    {
        #region Market Price

        [WebGet(UriTemplate = "market/{contract}/daily/{date_start}/{date_stop}")]
        public IEnumerable<MarketPriceBar> GetHS300(string contract, string date_start, string date_stop)
        {
            DateTime hashCode = DateTime.Now;
            WebOperationContext.Current.IncomingRequest.CheckConditionalRetrieve(hashCode);
            WebOperationContext.Current.OutgoingResponse.SetETag(hashCode.ToString());

            return new List<MarketPriceBar>();
        }

        [WebGet(UriTemplate = "market/{contract}/daily/{num}/before/{day}")]
        public IEnumerable<MarketPriceBar> GetHS300BeforeDays(string contract, string num, string day)
        {
            DateTime hashCode = DateTime.Now;
            WebOperationContext.Current.IncomingRequest.CheckConditionalRetrieve(hashCode);
            WebOperationContext.Current.OutgoingResponse.SetETag(hashCode.ToString());

            return new List<MarketPriceBar>();
        }

        [WebGet(UriTemplate = "market/futures/minute/{start}/{stop}")]
        public IEnumerable<MarketPriceBar> GetFuturesMinuteBars(string start, string stop)
        {
            DateTime hashCode = DateTime.Now;
            WebOperationContext.Current.IncomingRequest.CheckConditionalRetrieve(hashCode);
            WebOperationContext.Current.OutgoingResponse.SetETag(hashCode.ToString());

            return new List<MarketPriceBar>();
        }

        [WebGet(UriTemplate = "market/futures/daily/last")]
        public MarketPriceBar GetLastFuturesDayBars()
        {
            DateTime hashCode = DateTime.Now;
            WebOperationContext.Current.IncomingRequest.CheckConditionalRetrieve(hashCode);
            WebOperationContext.Current.OutgoingResponse.SetETag(hashCode.ToString());

            return new MarketPriceBar();
        }
        #endregion
    }
}
